﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Sharp.Portal.Other;

namespace Sharp.Portal
{
    /// <summary>
    /// 列特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class ColumnAttribute : System.Attribute
    {
        /// <summary>
     /// 列特性
     /// </summary>
        public ColumnAttribute()
        {
        }
        private bool? _locked;
        private bool? _cellWrap;

        /// <summary>
        /// 忽略
        /// </summary>
        [DefaultValue(false)]
        public virtual bool Ignore
        {
            get;
            set;
        }


        /// <summary>
        /// 锁定
        /// </summary>
        public virtual bool Locked
        {
            get => this._locked.HasValue && this._locked.Value;
            set => this._locked = value;
        }
        /// <summary>
        /// 对齐
        /// </summary>
        [DefaultValue(Alignment.Left)]
        public virtual Alignment Align { get; set; } = Alignment.Left;
        /// <summary>
        /// 数据索引
        /// </summary>
        [DefaultValue(null)]
        public virtual string DataIndex
        {
            get;
            set;
        }
        /// <summary>
        /// 可拖曳的
        /// </summary>
        [DefaultValue(true)]
        public virtual bool Draggable { get; set; } = true;
        /// <summary>
        /// 渲染编辑器的行为
        /// </summary>
        [DefaultValue(null)]
        public virtual string EditorRendererHandler
        {
            get;
            set;
        }
        /// <summary>
        /// 空文本
        /// </summary>
        [DefaultValue(null)]
        public virtual string EmptyCellText
        {
            get;
            set;
        }
        /// <summary>
        /// 可分组的
        /// </summary>
        [DefaultValue(true)]
        public virtual bool Groupable { get; set; } = true;
        /// <summary>
        /// 可隐藏的
        /// </summary>
        [DefaultValue(true)]
        public virtual bool Hideable { get; set; } = true;
        /// <summary>
        /// 是否启用菜单
        /// </summary>
        [DefaultValue(false)]
        public virtual bool MenuDisabled
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单文字
        /// </summary>
        [DefaultValue(null)]
        public virtual string MenuText
        {
            get;
            set;
        }
        /// <summary>
        /// 渲染器处理程序
        /// </summary>
        [DefaultValue(null)]
        public virtual string RendererHandler
        {
            get;
            set;
        }
        /// <summary>
        /// 范围
        /// </summary>
        [DefaultValue(null)]
        public virtual string Scope
        {
            get;
            set;
        }
        /// <summary>
        ///  可调整大小的 
        /// </summary>
        [DefaultValue(true)]
        public virtual bool Resizable { get; set; } = true;


        /// <summary>
        /// 允许排序
        /// </summary>
        public virtual bool Sortable { get; set; } = false;
        /// <summary>
        /// 应用于此列的表单元格的CSS类名.
        /// </summary>
        [DefaultValue(null)]
        public virtual string TdCls
        {
            get;
            set;
        }
        /// <summary>
        /// 文本
        /// </summary>
        [DefaultValue(null)]
        public virtual string Text
        {
            get;
            set;
        }
        /// <summary>
        /// 工具提示框
        /// </summary>
        [DefaultValue(null)]
        public virtual string ToolTip
        {
            get;
            set;
        }

        /// <summary>
        /// 能否换行
        /// </summary>
        public virtual bool CellWrap
        {
            get => this._cellWrap.HasValue && this._cellWrap.Value;
            set => this._cellWrap = new bool?(value);
        }
        /// <summary>
        /// 隐藏
        /// </summary>
        [DefaultValue(false)]
        public virtual bool Hidden
        {
            get;
            set;
        }
        /// <summary>
        /// 占位
        /// </summary>
        [DefaultValue(0)]
        public virtual int Flex
        {
            get;
            set;
        }
        /// <summary>
        /// 宽度
        /// </summary>
        [DefaultValue(0)]
        public virtual int Width
        {
            get;
            set;
        }

        /// <summary>
        /// 排序
        /// </summary>
        [DefaultValue(-1)]
        public virtual int Order { get; set; } = 2147483647;
    }
}
